<?php
namespace Home\Model;
use Think\Model;

class StationPartnerLogModel extends BaseModel{
    //请求快递log表
    protected $tableName = 'tp_station_partner_log';
    
    /**
     * @desc 更新第三方返回的请求状态
     * @author quyang
     * @update 2016-12-22
     */
    public function updateExpressData($parcelId,$method){
        $this->where(array('f_parcel_id'=>$parcelId))->save($method);
    }

    /**
     * @desc 查询包裹是否在第三方合作站点队列表
     * @author quyang
     * @update 2017-1-11
     */
    public function queryParcelData($where){
        $data = $this->where($where)->getField('f_id');
        return $data;
    }
    
    /**
     * @desc 获取快递快递数据和第三方站点数据
     * @author cheng 复制修改
     * @update 2017-06-16
     */
    public function queryExpressPartnerData($method){
        $data = $this->alias('sal')->where($method)
                ->field('
                    sal.f_parcel_id,
                    sal.f_station_id,
                    sal.f_type,
                    sal.f_mail_no,
                    sal.f_take_code,
                    sal.f_num,
                    sal.f_com_id,
                    sal.f_com_name,
                    sal.f_station_name,
                    sal.f_tel,
                    sal.f_common,
                    sal.f_recipient_name,
                    sal.f_recipient_mobile,
                    sal.f_partner_storage_status,
                    tp.f_partner_id,
                    tp.f_partner_name,
                    tp.f_partner_code,
                    u.f_professional,
                    u.f_address
                ')
                ->join('right join tp_third_partner as tp on sal.f_station_id=tp.f_station_id')
                ->join('left join tp_user as u on tp.f_station_id=u.f_user_id')
                ->select();
        return $data;
    }

}